function init() {
	$("a[text-name='notify']").bind('click', function() {
		var data = $(this).attr('data').split('-');
		var notify = {
			'notify.qid' : data[0],
			'notify.isnew' : data[1],
			'notify.type' : data[2]
		};
		var type=data[2];
		var html = this.innerHTML;
		var ul = $(this).parent().parent().parent().find("ul[name='ul']");
		if (html == '收起') {
			this.innerHTML = "展开";
			ul.css("display", "none");
		} else {
			var expansion = ul.attr('expansion');
			if (expansion == 'true') {
				var url = basePath + 'notify/index!notifyExpansion.action';
				Wenda.post(url, notify, function(users) {
					var div = ul.children().children();
					var a_templete = div.html();
					
					div.html('用户：');
					for ( var i = 0; i < users.length; i++) {
						var a = a_templete;
						var user = users[i];
						// var href=a.attr('href');
						// var tip=a.attr('data-tip');//p$fromuid$name
						a = a.replace('fromuid', user.fromuid);
						a = a.replace('name', user.name);
						a = a.replace('notify_id', user.id);
						a = a.replace('notify_qid', user.qid);
						a = a.replace('notify_uid', user.fromuid);
						a = a.replace('notify_aid', user.aid);
						a = a.replace('name', user.name);
						a = a.replace('user_id', user.fromuid);
						// a.attr('href',href);
						// a.attr('data-tip',tip);
						// a.html(user.name);
						div.append(a);
					}
					ul.attr('expansion', false);
					ul.css("display", "block");
				}, 'json');
			} else {
				ul.css("display", "block");
			}
			this.innerHTML = '收起';
		}
	});
}
init();
//删除通知
$(function(){
	$("a[name='delete']").bind("click",function(){
		if(isSubmit)return;
		var prent =$(this).parent();
		  var informid=$(this).attr("value");
		  var type=$(this).attr("data");
		var html =$(this).siblings("a[name='ignore']").html();
	Wenda.alert("确定删除该条通知吗？",'提示信息',{	
	"取消": function() {
			$(this).dialog("close");
		},
	"确定": function() {
		if(html==null||html==''){
		$.post(basePath+"json/inform!deleteInform.action",
		{'informid':informid},
		function(date){	
			prent.parent().parent().remove();
		}
		);
		}else{    
			$.post(basePath+"notify/index!deleteNotifygroup.action",
			{'type':type},
			function(date){	
				prent.parent().remove();
			}
			);	
			
		}
		$(this).dialog("close");
	}
	});	
	});
	});

//删除私信
$("a.delete").bind('click',function(){
	var deletemsg=$(this);
	var url=basePath+'notify/msg!delete.action';
	var mid=$(this).attr('mid');
	var type=$(this).attr('type');
	var msg={'mid':mid,'type':type};	
	Wenda.__tmp_content=$(this);
	Wenda.alert("确定删除该条私信吗？",'提示信息',{
		
	"取消": function() {
			$(this).dialog("close");
		},
	"确定": function() {
		Wenda.tmp=$(this);
		Wenda.post(url,msg,function(data){
			if(data.success){
				//window.location.reload();
				 
				Wenda.__tmp_content.parent().parent().parent().parent().parent().parent().slideUp();
			}
			else{
				alert("删除信息出错！");
				
				
			}
			Wenda.tmp.dialog("close");
			
			
		},'json');	 
	}
	});	
});

$('a.reply').bind('click',function(){
	$('#msgContent').focus();
});

/**
 * 接受好友请求
 */
$("a[name='receive']").bind("click",function() {
	var _uid = $(this).attr("uid");
	var _destuid = $(this).attr("destuid");
	var _notifyId = $(this).prev().attr("notifyid");
	var postData = {
		"uid" : _uid,
		"destuid" : _destuid,
		"notifyId" : _notifyId
	};
	$.post(basePath + '/relation/friend!receiveFried.action', postData, function(data) {
		alert("您已经成功接受了该好友的请求！");
		window.location.reload();
	});
});
	
/**
 * 拒绝好友请求
 */
$("a[name='repulse']").bind("click",function(){
	var _uid=$(this).attr("uid");
	var _destuid=$(this).attr("destuid");
	var _notifyId =$(this).prev().prev().attr("notifyid");
	var postData = {
			"uid":_uid,
			"destuid":_destuid,
			"notifyId":_notifyId
	};
	$.post(basePath+'/relation/friend!rejectFried.action',postData, function(data){
		alert("您已经拒绝了该好友的请求！");
		window.location.reload();
	});	
});





